﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace FontResize2
{
    public partial class Window1 : INotifyPropertyChanged
    {
        private int factor;
        public int Factor
        {
            get { return factor; }
            set
            {
                factor = value;
                RaisePropertyChanged("Factor");
                RaisePropertyChanged("FontSizeSmall");
                RaisePropertyChanged("FontSizeMedium");
                RaisePropertyChanged("FontSizeLarge");
            }
        }

        private int fontSizeSmall;
        public int FontSizeSmall
        {
            get { return fontSizeSmall + (fontSizeSmall * Factor / 10); }
            set
            {
                fontSizeSmall = value;
                RaisePropertyChanged("FontSizeSmall");
            }
        }

        private int fontSizeMedium;
        public int FontSizeMedium
        {
            get { return fontSizeMedium + (fontSizeMedium * Factor / 10); }
            set
            {
                fontSizeMedium = value;
                RaisePropertyChanged("FontSizeMedium");
            }
        }

        private int fontSizeLarge;
        public int FontSizeLarge
        {
            get { return fontSizeLarge + (fontSizeLarge * Factor / 10); }
            set
            {
                fontSizeLarge = value;
                RaisePropertyChanged("FontSizeLarge");
            }
        }

        public Window1()
        {
            InitializeComponent();
            Factor = 0;
            FontSizeSmall = 10;
            FontSizeMedium = 20;
            FontSizeLarge = 30;
        }

        public event PropertyChangedEventHandler PropertyChanged;
        protected void RaisePropertyChanged(string propertyName)
        {
            var handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        private void PlusClick(object sender, RoutedEventArgs e)
        {
            Factor++;
        }

        private void MinusClick(object sender, RoutedEventArgs e)
        {
            Factor--;
        }
    }
}
